package com.bt.dmdb.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import org.hibernate.annotations.Type;
import org.joda.time.LocalDateTime;

import com.bt.dmdb.json.converter.JsonDateDeserializer;
import com.bt.dmdb.json.converter.JsonDateSerializer;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@Entity
@Table(name = "LOGIN_USER")
@SuppressWarnings("serial")
@JsonAutoDetect
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@id", scope = LoginUser.class)
public class LoginUser implements java.io.Serializable {

    private Long id;
    private String firstname;
    private String lastname;
    private String emailid;
    private String password;
    private Role role;
    
    //private final LoginUser createdBy = new LoginUser(new Long(1),"admin","admin","admin1","admin@gmail.com",new Role(new Long(1),"admin"),null,null,null,null);
	//private final LoginUser updatedBy = new LoginUser(new Long(1),"admin","admin","admin1","admin@gmail.com",new Role(new Long(1),"admin"),null,null,null,null);
    private Long createdBy;
    private Long updatedBy;
    
    
	//@Temporal(TemporalType.TIMESTAMP)
	private LocalDateTime creationDate;
	
	//@Temporal(TemporalType.TIMESTAMP)
	private LocalDateTime modificationDate;	
    
	private Set<CustomerDetails> customerDetailsCreatedby = new HashSet<CustomerDetails>(0);
    private Set<CustomerDetails> customerDetailsUpdatedby = new HashSet<CustomerDetails>(0);
    
    /* */private Set<BusinessNature> businessNatureCreatedby = new HashSet<BusinessNature>(0);
    private Set<BusinessNature> businessNatureUpdatedby = new HashSet<BusinessNature>(0);
    
    /* */ private Set<Locations> locationsCreatedby = new HashSet<Locations>(0);
    private Set<Locations> locationsUpdatedby = new HashSet<Locations>(0);
    
    private Set<StocksDistribution> stocksDistributionCreatedby = new HashSet<StocksDistribution>(0);
    private Set<StocksDistribution> stocksDistributionUpdatedby = new HashSet<StocksDistribution>(0);
    
    private Set<SourceIncome> sourceIncomeCreatedby = new HashSet<SourceIncome>(0);
    private Set<SourceIncome> sourceIncomeUpdatedby = new HashSet<SourceIncome>(0);
    
    private Set<RestrictedDistributor> restrictedDistributorCreatedby = new HashSet<RestrictedDistributor>(0);
    private Set<RestrictedDistributor> restrictedDistributorUpdatedby = new HashSet<RestrictedDistributor>(0);
    
    private Set<Regulators> regulatorsCreatedby = new HashSet<Regulators>(0);
    private Set<Regulators> regulatorsUpdatedby = new HashSet<Regulators>(0);
    
    private Set<EagPassiveIncome> eagPassiveIncomeCreatedby = new HashSet<EagPassiveIncome>(0);
    private Set<EagPassiveIncome> eagPassiveIncomeUpdatedby = new HashSet<EagPassiveIncome>(0);
    
    private Set<Market> marketCreatedby = new HashSet<Market>(0);
    private Set<Market> marketUpdatedby = new HashSet<Market>(0);
    
    private Set<MemberStatus> memberStatusCreatedby = new HashSet<MemberStatus>(0);
    private Set<MemberStatus> memberStatusUpdatedby = new HashSet<MemberStatus>(0);
    
    private Set<Contact> contactCreatedby = new HashSet<Contact>(0);
    private Set<Contact> contactUpdatedby = new HashSet<Contact>(0);
    
    
    public LoginUser() {
    }

	public LoginUser(Long id, String firstname, String lastname,
			String emailid, String password, Role role, LocalDateTime creationDate,
			LocalDateTime modificationDate,
			Set<CustomerDetails> customerDetailsCreatedby,
			Set<CustomerDetails> customerDetailsUpdatedby, Long createdBy,Long updatedBy,
			/**/Set<BusinessNature> businessNatureCreatedby,
			Set<BusinessNature> businessNatureUpdatedby,
			/* */Set<Locations> locationsCreatedby,
			Set<Locations> locationsUpdatedby,
			Set<StocksDistribution> stocksDistributionCreatedby,
			Set<StocksDistribution> stocksDistributionUpdatedby,
			Set<SourceIncome> sourceIncomeCreatedby,
			Set<SourceIncome> sourceIncomeUpdatedby,
			Set<RestrictedDistributor> restrictedDistributorCreatedby,
			Set<RestrictedDistributor> restrictedDistributorUpdatedby,
			Set<Regulators> regulatorsCreatedby,
			Set<Regulators> regulatorsUpdatedby,
			Set<EagPassiveIncome> eagPassiveIncomeCreatedby,
			Set<EagPassiveIncome> eagPassiveIncomeUpdatedby,
			Set<Market> marketCreatedby, Set<Market> marketUpdatedby,
			Set<MemberStatus> memberStatusCreatedby,
			Set<MemberStatus> memberStatusUpdatedby,
			Set<Contact> contactCreatedby, Set<Contact> contactUpdatedby
			) {
		super();
		this.id = id;
		this.firstname = firstname;
		this.lastname = lastname;
		this.emailid = emailid;
		this.password = password;
		this.role = role;
		this.creationDate = creationDate;
		this.modificationDate = modificationDate;
		/**/this.customerDetailsCreatedby = customerDetailsCreatedby;
		this.customerDetailsUpdatedby = customerDetailsUpdatedby;
		this.createdBy=createdBy;
		this.updatedBy=updatedBy;
		/* */this.businessNatureCreatedby = businessNatureCreatedby;
		this.businessNatureUpdatedby = businessNatureUpdatedby;
		/* */this.locationsCreatedby = locationsCreatedby;
		this.locationsUpdatedby = locationsUpdatedby;
		this.stocksDistributionCreatedby = stocksDistributionCreatedby;
		this.stocksDistributionUpdatedby = stocksDistributionUpdatedby;
		this.sourceIncomeCreatedby = sourceIncomeCreatedby;
		this.sourceIncomeUpdatedby = sourceIncomeUpdatedby;
		this.restrictedDistributorCreatedby = restrictedDistributorCreatedby;
		this.restrictedDistributorUpdatedby = restrictedDistributorUpdatedby;
		this.regulatorsCreatedby = regulatorsCreatedby;
		this.regulatorsUpdatedby = regulatorsUpdatedby;
		this.eagPassiveIncomeCreatedby = eagPassiveIncomeCreatedby;
		this.eagPassiveIncomeUpdatedby = eagPassiveIncomeUpdatedby;
		this.marketCreatedby = marketCreatedby;
		this.marketUpdatedby = marketUpdatedby;
		this.memberStatusCreatedby = memberStatusCreatedby;
		this.memberStatusUpdatedby = memberStatusUpdatedby;
		this.contactCreatedby = contactCreatedby;
		this.contactUpdatedby = contactUpdatedby;
	}

	@Id
    @GeneratedValue(generator = "userIG", strategy = GenerationType.TABLE)
    @TableGenerator(name = "userIG", table = "jpa_sequences", pkColumnName = "name", pkColumnValue = "LoginUser", allocationSize = 10, valueColumnName = "next_hi_value")
    @Column(name = "ID")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "firstname", nullable = false, length = 50)
    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    @Column(name = "lastname", nullable = false, length = 50)
    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    @Column(name = "emailid", nullable = false, length = 50)
    public String getEmailid() {
        return emailid;
    }

    public void setEmailid(String emailid) {
        this.emailid = emailid;
    }

    @Column(name = "password", nullable = false, length = 50)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ROLE_ID", nullable = false)
    public Role getRole() {
        return role;
    } 


	public void setRole(Role role) {
        this.role = role;
    }
	
	

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy", cascade = CascadeType.ALL)
	public Set<CustomerDetails> getCustomerDetailsCreatedby() {
		return customerDetailsCreatedby;
	}

	public void setCustomerDetailsCreatedby(
			Set<CustomerDetails> customerDetailsCreatedby) {
		this.customerDetailsCreatedby = customerDetailsCreatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy", cascade = CascadeType.ALL)
	public Set<CustomerDetails> getCustomerDetailsUpdatedby() {
		return customerDetailsUpdatedby;
	}

	public void setCustomerDetailsUpdatedby(
			Set<CustomerDetails> customerDetailsUpdatedby) {
		this.customerDetailsUpdatedby = customerDetailsUpdatedby;
	}
	
	/**/	@OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy", cascade = CascadeType.ALL)
	public Set<BusinessNature> getBusinessNatureCreatedby() {
		return businessNatureCreatedby;
	}

	
	public void setBusinessNatureCreatedby(
			Set<BusinessNature> businessNatureCreatedby) {
		this.businessNatureCreatedby = businessNatureCreatedby;
	}

		@OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy", cascade = CascadeType.ALL)
	public Set<BusinessNature> getBusinessNatureUpdatedby() {
		return businessNatureUpdatedby;
	}

	public void setBusinessNatureUpdatedby(
			Set<BusinessNature> businessNatureUpdatedby) {
		this.businessNatureUpdatedby = businessNatureUpdatedby;
	}

	/* */@OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy", cascade = CascadeType.ALL)
	public Set<Locations> getLocationsCreatedby() {
		return locationsCreatedby;
	}

	public void setLocationsCreatedby(
			Set<Locations> locationsCreatedby) {
		this.locationsCreatedby = locationsCreatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy", cascade = CascadeType.ALL)
	public Set<Locations> getLocationsUpdatedby() {
		return locationsUpdatedby;
	}

	public void setLocationsUpdatedby(
			Set<Locations> locationsUpdatedby) {
		this.locationsUpdatedby = locationsUpdatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy", cascade = CascadeType.ALL)
	public Set<StocksDistribution> getStocksDistributionCreatedby() {
		return stocksDistributionCreatedby;
	}

	public void setStocksDistributionCreatedby(
			Set<StocksDistribution> stocksDistributionCreatedby) {
		this.stocksDistributionCreatedby = stocksDistributionCreatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy", cascade = CascadeType.ALL)
	public Set<StocksDistribution> getStocksDistributionUpdatedby() {
		return stocksDistributionUpdatedby;
	}

	public void setStocksDistributionUpdatedby(
			Set<StocksDistribution> stocksDistributionUpdatedby) {
		this.stocksDistributionUpdatedby = stocksDistributionUpdatedby;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy", cascade = CascadeType.ALL)
	public Set<SourceIncome> getSourceIncomeCreatedby() {
		return sourceIncomeCreatedby;
	}

	public void setSourceIncomeCreatedby(Set<SourceIncome> sourceIncomeCreatedby) {
		this.sourceIncomeCreatedby = sourceIncomeCreatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy", cascade = CascadeType.ALL)
	public Set<SourceIncome> getSourceIncomeUpdatedby() {
		return sourceIncomeUpdatedby;
	}

	public void setSourceIncomeUpdatedby(Set<SourceIncome> sourceIncomeUpdatedby) {
		this.sourceIncomeUpdatedby = sourceIncomeUpdatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy", cascade = CascadeType.ALL)
	public Set<RestrictedDistributor> getRestrictedDistributorCreatedby() {
		return restrictedDistributorCreatedby;
	}

	public void setRestrictedDistributorCreatedby(
			Set<RestrictedDistributor> restrictedDistributorCreatedby) {
		this.restrictedDistributorCreatedby = restrictedDistributorCreatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy", cascade = CascadeType.ALL)
	public Set<RestrictedDistributor> getRestrictedDistributorUpdatedby() {
		return restrictedDistributorUpdatedby;
	}

	public void setRestrictedDistributorUpdatedby(
			Set<RestrictedDistributor> restrictedDistributorUpdatedby) {
		this.restrictedDistributorUpdatedby = restrictedDistributorUpdatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy", cascade = CascadeType.ALL)
	public Set<Regulators> getRegulatorsCreatedby() {
		return regulatorsCreatedby;
	}

	public void setRegulatorsCreatedby(Set<Regulators> regulatorsCreatedby) {
		this.regulatorsCreatedby = regulatorsCreatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy", cascade = CascadeType.ALL)
	public Set<Regulators> getRegulatorsUpdatedby() {
		return regulatorsUpdatedby;
	}

	public void setRegulatorsUpdatedby(Set<Regulators> regulatorsUpdatedby) {
		this.regulatorsUpdatedby = regulatorsUpdatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy", cascade = CascadeType.ALL)
	public Set<EagPassiveIncome> getEagPassiveIncomeCreatedby() {
		return eagPassiveIncomeCreatedby;
	}

	public void setEagPassiveIncomeCreatedby(
			Set<EagPassiveIncome> eagPassiveIncomeCreatedby) {
		this.eagPassiveIncomeCreatedby = eagPassiveIncomeCreatedby;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy", cascade = CascadeType.ALL)
	public Set<EagPassiveIncome> getEagPassiveIncomeUpdatedby() {
		return eagPassiveIncomeUpdatedby;
	}

	public void setEagPassiveIncomeUpdatedby(
			Set<EagPassiveIncome> eagPassiveIncomeUpdatedby) {
		this.eagPassiveIncomeUpdatedby = eagPassiveIncomeUpdatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy", cascade = CascadeType.ALL)
	public Set<Market> getMarketCreatedby() {
		return marketCreatedby;
	}

	public void setMarketCreatedby(Set<Market> marketCreatedby) {
		this.marketCreatedby = marketCreatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy", cascade = CascadeType.ALL)
	public Set<Market> getMarketUpdatedby() {
		return marketUpdatedby;
	}

	public void setMarketUpdatedby(Set<Market> marketUpdatedby) {
		this.marketUpdatedby = marketUpdatedby;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy", cascade = CascadeType.ALL)
	public Set<MemberStatus> getMemberStatusCreatedby() {
		return memberStatusCreatedby;
	}

	public void setMemberStatusCreatedby(Set<MemberStatus> memberStatusCreatedby) {
		this.memberStatusCreatedby = memberStatusCreatedby;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy", cascade = CascadeType.ALL)
	public Set<MemberStatus> getMemberStatusUpdatedby() {
		return memberStatusUpdatedby;
	}

	public void setMemberStatusUpdatedby(Set<MemberStatus> memberStatusUpdatedby) {
		this.memberStatusUpdatedby = memberStatusUpdatedby;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy", cascade = CascadeType.ALL)
	public Set<Contact> getContactCreatedby() {
		return contactCreatedby;
	}

	public void setContactCreatedby(Set<Contact> contactCreatedby) {
		this.contactCreatedby = contactCreatedby;
	}

	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy", cascade = CascadeType.ALL)
	public Set<Contact> getContactUpdatedby() {
		return contactUpdatedby;
	}

	public void setContactUpdatedby(Set<Contact> contactUpdatedby) {
		this.contactUpdatedby = contactUpdatedby;
	}


	@Column(name = "created_by")
	public Long getCreatedBy() {
		return createdBy;
	}
	
	public void setCreatedBy(Long createdBy) {
		this.createdBy = createdBy;
	}

	@Column(name = "updated_by")
	public Long getUpdatedBy() {
		return updatedBy;
	}

	public void setUpdatedBy(Long updatedBy) {
		this.updatedBy = updatedBy;
	}
	

	@Column(name = "creation_date")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    @JsonSerialize(using = JsonDateSerializer.class)
    @JsonDeserialize(using = JsonDateDeserializer.class)
	public LocalDateTime getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(LocalDateTime creationDate) {
		this.creationDate = creationDate;
	}
	
	
	@Column(name = "modification_date")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDateTime")
    @JsonSerialize(using = JsonDateSerializer.class)
    @JsonDeserialize(using = JsonDateDeserializer.class)
	public LocalDateTime getModificationDate() {
		return modificationDate;
	}

	public void setModificationDate(LocalDateTime modificationDate) {
		this.modificationDate = modificationDate;
	}

}
